package javamusic.Servlet.Cliente;

import java.io.IOException;
import java.util.Collection;

import javamusic.excepcion.DAOExcepcion;
import javamusic.modelo.ReservaCliente;

import javamusic.negocio.GestionReservaCliente;


import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import junit.framework.Assert;

/**
 * Servlet implementation class ServletClienteSala
 */
@WebServlet("/ServletClienteSala")
public class ServletClienteSala extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletClienteSala() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String nombre = request.getParameter("nombre");
		GestionReservaCliente negocio = new GestionReservaCliente();
try{
	Collection<ReservaCliente> salas = negocio.buscarPorNombre(nombre);
	for (ReservaCliente sala : salas) {
		sala.getNombresala();
		sala.getCapacidad();
		sala.getDescripcion();
		sala.getNombrelocal();
		
					
	}
	RequestDispatcher rd = request.getRequestDispatcher("/FormReservaClienteSala.jsp");
	request.setAttribute("SALAS_DISPONIBLES", salas);
	rd.forward(request, response);
} catch (DAOExcepcion e){
	Assert.fail("Fallo la Insercion:" + e.getMessage());
}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		// TODO Auto-generated method stub
		String nombre = request.getParameter("nombre");
		GestionReservaCliente negocio = new GestionReservaCliente();
try{
	Collection<ReservaCliente> salas = negocio.buscarPorNombre(nombre);
	for (ReservaCliente sala : salas) {
		sala.getNombresala();
		sala.getCapacidad();
		sala.getDescripcion();
		sala.getNombrelocal();
		
					
	}
	RequestDispatcher rd = request.getRequestDispatcher("/FormReservaClienteSala.jsp");
	request.setAttribute("SALAS_DISPONIBLES", salas);
	rd.forward(request, response);
} catch (DAOExcepcion e){
	Assert.fail("Fallo la Insercion:" + e.getMessage());
}

	



	}

}
